Skip to content

fix(web): template-elide probe must mirror the walk's tag-name derivation - #911

Merged
ormastes merged 1 commit into
mainfrom
work/web-perf-round10-probe-fix-2026-09-13
Sep 13, 2026
Merged

ormastes merged 1 commit into
mainfrom
work/web-perf-round10-probe-fix-2026-09-13

Conversation

@ormastes

Copy link
Copy Markdown
Owner

Correction to #910, found by review the same day.

The defect

#910's fast path probed for the contiguous substring <template. That is not equivalent to the walk it replaces. The walk derives its tag name from

val inner = lower.substring(lt + 1, gt).trim()

so < template> and </ template> reach name == "template" while containing no contiguous <template — and the fast path returned the document unchanged where the walk elides a template body. #910's twelve adversarial fixtures had no whitespace-after-< shape, which is exactly why its spec passed.

The fix, in round-9 order

  1. The shapes were added to the adversarial fixture FIRST and the spec confirmed failing on them:
    [12] MISMATCH fast_len=68 slow_len=34 [13] MISMATCH fast_len=70 slow_len=34
  2. Then the probe was replaced by _html_template_tag_present, which mirrors the walk's own derivation: for each literal template occurrence, walk back over whitespace, optionally one / and more whitespace, and test for <. Bounded by the occurrence count (2-3 per catalog page), not by document length.

A bare-word probe (find_from(lower, "template", 0)) would have been trivially correct and is not usable: grep -ic template finds the word on all eight catalog pages (prose and grid-template-*), so it would have deleted the entire win. That fixture row is now in the spec so the shortcut cannot be taken later.

The win survives

2 alternating A/B pairs on the corrected probe, on a much busier host than #910's sweep (sel_match 911-947 vs 608-681):

pair pp_css before after cas_tail b/a sel_match b/a
1 1223 554 889 / 877 947 / 916
2 1165 551 861 / 855 944 / 911

Same -55%, controls flat within each pair, 8/8 Draw IR digests identical on all four runs.

Gates

gate verdict
web_template_elide_fastpath_equivalence_spec 2/2 pass, 16 adversarial documents (up from 12), 0 mismatches
Draw IR sha256 8/8 identical both sides on all 4 runs
GPU boundary audit PASS — 2 frame(s) audited, host_pixel_iterations=0, readbacks_per_frame<=1, submits_per_frame<=1
conflict-markers / conflict-tree / tree-size / no-revert / divergence-delta / guard-wiring all PASS

Also fixes a wrong claim in the round-10 doc: tail_inline is ONE unmemoized apply_decls_without_display_on_writing_mode call (on inline_normal), not three — the combined_important_decls and inline_important siblings both sit at the ~44 ms timer floor. The doc gains a Correction section recording this whole episode.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi

…tion

PR #910's fast path probed for the contiguous substring `<template`. That is
NOT equivalent to the walk it replaces: the walk derives its tag name from
`lower.substring(lt + 1, gt).trim()`, so `< template>` and `</ template>` reach
`name == "template"` while containing no contiguous `<template`, and the fast
path returned a document whose template body the walk elides. #910's fixture set
had no whitespace-after-`<` shape, which is why its spec passed.

Round-9 order: the shapes were added to the adversarial fixture FIRST and the
spec confirmed failing on them (`[12] MISMATCH fast_len=68 slow_len=34`,
`[13] MISMATCH fast_len=70 slow_len=34`), then the probe was replaced.

`_html_template_tag_present` mirrors the walk's own derivation: for each literal
`template` occurrence, walk back over whitespace, optionally one `/` and more
whitespace, and test for `<`. Bounded by the occurrence count (2-3 per catalog
page), not by document length.

A bare-word probe would have been trivially correct and is NOT usable: all eight
catalog pages contain the word `template` (prose and `grid-template-*`), so it
would have deleted the entire win. That fixture row is now in the spec so the
shortcut cannot be taken later.

Re-measured on the corrected probe, 2 alternating A/B pairs on a busier host
(sel_match 911-947 vs 608-681 in #910's sweep): pp_css 1223 -> 554 and
1165 -> 551 ms across the eight pages, same -55%, controls flat within each
pair, 8/8 Draw IR digests identical on all four runs.

Gates: equivalence spec 2/2 (16 adversarial documents, up from 12); GPU boundary
audit PASS.

Doc: doc/10_metrics/ui/web_perf_round10_2026-09-13.md gains a Correction section
at the top, and the `tail_inline` follow-up note is fixed (one unmemoized apply,
not three -- the other two sit at the timer floor).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi
@ormastes
ormastes merged commit c9790ff into main Sep 13, 2026
1 of 35 checks passed
@ormastes
ormastes deleted the work/web-perf-round10-probe-fix-2026-09-13 branch September 13, 2026 13:11

This branch was successfully deployed

No deployments
self-review-admission — 3a84f422 Deployed Sep 13, 2026 by ormastes via Invalidate changed PR self-review state #5022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant